//
// Created by haoba on 2018/4/1.
//

#ifndef TKDATABASE_RECORDIO_H
#define TKDATABASE_RECORDIO_H

#include <cstdint>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <string>
#include "../../config/config.h"

using namespace std;

struct serializeBuff {
    int32_t len;
    int32_t off;
    char* buff;
};

void Edeallocate_String(char **s);
void Edeallocate_Buffer(struct buffer *b);
void Edeallocate_vector(void *d);

int Eserialize_Int(struct serializeBuff * buff,int32_t * d);
int Eserialize_Long(struct serializeBuff * buff,int64_t * d);
int Eserialize_Bool(struct serializeBuff * buff,bool * d);
int Eserialize_String(struct serializeBuff * buff,string & d);
int Eserialize_CString(struct serializeBuff * buff,int32_t len,char ** d);

int Edeserialize_Int(struct serializeBuff * buff,int32_t  * d);
int Edeserialize_Long(struct serializeBuff * buff,int64_t  * d);
int Edeserialize_Bool(struct serializeBuff * buff,bool  * d);
int Edeserialize_String(struct serializeBuff * buff,string & d);
int Edeserialize_CString(struct serializeBuff * buff,char  ** d);


struct serializeBuff *create_serialize_buff(void);
struct serializeBuff *create_serialize_buff(char * buff,int32_t len);
void close_serialize_buff(struct serializeBuff *buff);
char *get_buff(struct oarchive *);
int get_buff_len(struct oarchive *);

int64_t Ezoo_htonll(int64_t v);

#endif //TKDATABASE_RECORDIO_H
